package com.springcloud.sc.ucpv5.client.commondata;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import com.springcloud.sc.ucpv5.client.commondata.tree.IDcsTreeNode;

public abstract class ModelBase implements IDcsTreeNode {
	protected static final ArrayList EMPTY_LIST = new ArrayList();

	private IDcsTreeNode parent;
    private CopyOnWriteArrayList<IDcsTreeNode> parents;
	protected int level;
    protected BaseListModel baseListModel = new BaseListModel(this);

    public BaseListModel getListModel() {
	return baseListModel;
    }
	public Object getParent() {
		return parent;
	}

	public void setParent(IDcsTreeNode parent) {
		this.parent = parent;

	if (parents == null) {
	    parents = new CopyOnWriteArrayList<IDcsTreeNode>();
	}
	if (!parents.contains(parent)) {
	    parents.add(parent);
	}
    }

	public void rmvParent(IDcsTreeNode parent) {
		this.parent = null;

		if (parents != null) {
			parents.remove(parent);
		}
	}

    public CopyOnWriteArrayList<IDcsTreeNode> getParents() {
		return parents;
	}

    public List getChildren() {
		return EMPTY_LIST;
	}

	public int getLevel() {
		return level;
	}

	public String getIconDesc(String status) {
		return "";
	}

	public boolean hasChildren() {
		return false;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public abstract int[] getSupportField();

	public abstract String[] getFieldNames();

	public String getTipLabel() {
		StringBuffer buf = new StringBuffer();

		return buf.toString();
	}

	private boolean isRoleVisibale = true;

	public boolean isRoleVisibale() {
		return isRoleVisibale;
	}

	public void setRoleVisibale(boolean isRoleVisibale) {
		this.isRoleVisibale = isRoleVisibale;
	}
}
